---@class Battle.BuffEffect1:Battle.BuffEffectBase
---属性增减buff脚本
local BuffEffect1 = Battle.CreateClass("BuffEffect1",Battle.BuffEffectBase)
Battle.BuffEffect1 = BuffEffect1
function BuffEffect1:OnCreate(buff)
    ---@type Battle.Buffer
    self.buff = buff
    local param = decodeJsonStrToTable(self.buff.cfg.f_EffectParameter)
    self.attrList = {}
    for k,v in pairs(param) do
        self.attrList[v[1]] = v[2]
    end
end

---buff生效时
function BuffEffect1:OnBuffStart(...)
    --触发属性增减
    local actor = Battle.ActorManager.GetActor(self.buff.targetId)
    for k=1,self.buff.overlay do
        actor.attrSystem:AddAttrList(self.attrList)
    end
end
---相同类型时刷新(更新buff层数、等级、持续时间等)
function BuffEffect1:OnBuffRefresh(overlay,old)
    local actor = Battle.ActorManager.GetActor(self.buff.targetId)
    if old > overlay then
        for k=1,old - overlay do
            actor.attrSystem:RemoveAttrList(self.attrList)
        end
    end
    if old < overlay then
        for k=1,overlay - old do
            actor.attrSystem:AddAttrList(self.attrList)
        end
    end
end
---当buff销毁前(还未从buff容器中移除)
function BuffEffect1:OnBuffRemove()
    local actor = Battle.ActorManager.GetActor(self.buff.targetId)
    for k=1,self.buff.overlay do
        actor.attrSystem:RemoveAttrList(self.attrList)
    end
end

return BuffEffect1